#include "StdAfx.h"

SettingsDialog* Singleton<SettingsDialog>::m_instance = 0;

SettingsDialog::SettingsDialog() : mBrushType(0)
{
	m_dialog = new Dialog(100, 100, 9, 8, "Settings");
	m_dialog->AddText(20, 50, "Heightlines: ");
	m_hlEnabled = m_dialog->AddCheckbox(this, 120, 42, "Enabled", &SettingsDialog::HLCheckProc);
	m_hlEnabled->m_state = 1;
	m_dialog->AddText(20, 80, "Heightline distance: ");
	Scrollbar<SettingsDialog>* pBar = m_dialog->AddScrollbar(170, 80, 100, this, &SettingsDialog::ScrollBarProc);
	pBar->SetRange(100, 10000);
	pBar->SetValue(2000);
	m_hlDist = 20;
	sUI.AddElement(m_dialog);
	mSolid = m_dialog->AddRadioButton(20, 120, this, &SettingsDialog::TypeSolidProc);
	mSolid->SetText("Solid");
	mSolid->Check();
	mOuter = m_dialog->AddRadioButton(130, 120, this, &SettingsDialog::TypeOuterProc);
	mOuter->SetText("Outer");
	mNone = m_dialog->AddRadioButton(20, 140, this, &SettingsDialog::TypeNoneProc);
	mNone->SetText("None");
	mAnimCur = m_dialog->AddRadioButton(20, 170, this, &SettingsDialog::TypeAnimProc);
	mAnimCur->SetText("Animated cursor");
	mNormCur = m_dialog->AddRadioButton(160, 170, this, &SettingsDialog::TypeNormProc);
	mNormCur->SetText("Normal cursor");
	mAnimCur->Check();
}

void SettingsDialog::ScrollBarProc(Scrollbar<SettingsDialog>* pBar, ui32 value)
{
	m_hlDist = value / 100;
}

void SettingsDialog::TypeSolidProc(RadioButton<SettingsDialog>* button, bool checked) {
	if(checked) {
		mOuter->Uncheck();
		mNone->Uncheck();
		mBrushType = 0;
	} else {
		mSolid->Check();
	}
}

void SettingsDialog::TypeOuterProc(RadioButton<SettingsDialog>* button, bool checked) {
	if(checked) {
		mSolid->Uncheck();
		mNone->Uncheck();
		mBrushType = 1;
	} else {
		mOuter->Check();
	}
}

void SettingsDialog::TypeNoneProc(RadioButton<SettingsDialog>* button, bool checked) {
	if(checked) {
		mSolid->Uncheck();
		mOuter->Uncheck();
		mBrushType = 2;
	} else {
		mNone->Check();
	}
}

void SettingsDialog::TypeAnimProc(RadioButton<SettingsDialog>* button, bool checked) {
	if(checked) {
		mNormCur->Uncheck();
		sWindow.setCursor(true);
	} else {
		mAnimCur->Check();
	}
}

void SettingsDialog::TypeNormProc(RadioButton<SettingsDialog>* button, bool checked) {
	if(checked) {
		mAnimCur->Uncheck();
		sWindow.setCursor(false);
	} else {
		mNormCur->Check();
	}
}